import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 图号配置信息 */
export interface DrawConfig {
  id: number // id
  customerAccount?: string // 客户账号
  customerName: string // 客户
  storeLocation: string // 仓库地点
  storeName: string // 仓库名称
  drawingNumber: string // 图号
  productName: string // 品名
}

// 图号配置 API
export const DrawConfigApi = {
  // 查询图号配置分页
  getDrawConfigPage: async (params: any) => {
    return await request.get({ url: `/business/draw-config/page`, params })
  },

  // 查询图号配置分页
  getDrawConfigListQuery: async (params: any) => {
    return await request.get({ url: `/business/draw-config/listQuery`, params })
  },

  // 查询图号配置
  getDrawConfigList: async (params: any) => {
    return await request.get({ url: `/business/draw-config/list`, params })
  },

  // 查询图号配置详情
  getDrawConfig: async (id: number) => {
    return await request.get({ url: `/business/draw-config/get?id=` + id })
  },

  // 获取任意一个配置
  getDrawConfigOne: async () => {
    return await request.get({ url: `/business/draw-config/getDrawConfigOne` })
  },

  // 新增图号配置
  createDrawConfig: async (data: DrawConfig) => {
    return await request.post({ url: `/business/draw-config/create`, data })
  },

  // 修改图号配置
  updateDrawConfig: async (data: DrawConfig) => {
    return await request.put({ url: `/business/draw-config/update`, data })
  },

  // 删除图号配置
  deleteDrawConfig: async (id: number) => {
    return await request.delete({ url: `/business/draw-config/delete?id=` + id })
  },

  /** 批量删除图号配置 */
  deleteDrawConfigList: async (ids: number[]) => {
    return await request.delete({ url: `/business/draw-config/delete-list?ids=${ids.join(',')}` })
  },

  // 导出图号配置 Excel
  exportDrawConfig: async (params) => {
    return await request.download({ url: `/business/draw-config/export-excel`, params })
  },

  // 下载导入模板
  importTemplate: async () => {
    return request.download({ url: '/business/draw-config/get-import-template' })
  }
}
